#include "Edge.h"


Edge::Edge(Point* point1, Point* point2)
{
    firstPoint = point1;
    secondPoint = point2;
	adjacentTriangle1 = NULL;
	adjacentTriangle2 = NULL;
	status = Edge::CLOSED;
}

//Create a constructor of Edge taking in two points
Edge::Edge(Point* point1, Point* point2, Triangle* neighbour1, Triangle* neighbour2)
{
    firstPoint = point1;
    secondPoint = point2;
	adjacentTriangle1 = neighbour1;
	adjacentTriangle2 = neighbour2;
	status = Edge::CLOSED;
}

//virtual destructor of Edge
Edge::~Edge()
{
}

//returns first point of the edge
Point* Edge::getPoint1()
{
    return this->firstPoint;
}

//returns second point of the edge
Point* Edge::getPoint2()
{
    return this->secondPoint;
}

//returns the triangle using the edge
Triangle* Edge::getTriangle1()
{
    return this->adjacentTriangle1;
}

//returns the triangle using the edge
Triangle* Edge::getTriangle2()
{
    return this->adjacentTriangle2;
}

bool Edge::equals(Edge* other)
{
    if ((other->getPoint1()->equals(this->firstPoint)&& other->getPoint2()->equals(this->secondPoint)) ||
    (other->getPoint2()->equals(this->firstPoint)&& other->getPoint1()->equals(this->secondPoint)))
    return true;
    else return false;
}

//prints the edges
void Edge::print()
{
	cout<<"( " << this->firstPoint->getX()<< ", " << this->firstPoint->getY() << " )  " << "( " << this->secondPoint->getX()<< ", " << this->secondPoint->getY() << " )    " << "Status: "<< status<<endl;
}
